package cn.iocoder.yudao.module.system.controller.admin.mini.group.order.dal.mysql.grouporder;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.order.controller.admin.grouporder.vo.GroupOrderExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.order.controller.admin.grouporder.vo.GroupOrderPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.order.dal.dataobject.grouporder.GroupOrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 团购订单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface GroupOrderMapper extends BaseMapperX<GroupOrderDO> {

    default PageResult<GroupOrderDO> selectPage(GroupOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GroupOrderDO>()
                .betweenIfPresent(GroupOrderDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GroupOrderDO::getOrderCode, reqVO.getOrderCode())
                .likeIfPresent(GroupOrderDO::getNickName, reqVO.getNickName())
                .eqIfPresent(GroupOrderDO::getVipLevel, reqVO.getVipLevel())
                .eqIfPresent(GroupOrderDO::getPrize, reqVO.getPrize())
                .betweenIfPresent(GroupOrderDO::getAddTime, reqVO.getAddTime())
                .eqIfPresent(GroupOrderDO::getGoods, reqVO.getGoods())
                .eqIfPresent(GroupOrderDO::getGroupGoodsId, reqVO.getGroupGoodsId())
                .eqIfPresent(GroupOrderDO::getPayStatus, reqVO.getPayStatus())
                .betweenIfPresent(GroupOrderDO::getPayTime, reqVO.getPayTime())
                .eqIfPresent(GroupOrderDO::getOrderStatus, reqVO.getOrderStatus())
                .orderByDesc(GroupOrderDO::getId));
    }

    default List<GroupOrderDO> selectList(GroupOrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GroupOrderDO>()
                .betweenIfPresent(GroupOrderDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GroupOrderDO::getOrderCode, reqVO.getOrderCode())
                .likeIfPresent(GroupOrderDO::getNickName, reqVO.getNickName())
                .eqIfPresent(GroupOrderDO::getVipLevel, reqVO.getVipLevel())
                .eqIfPresent(GroupOrderDO::getPrize, reqVO.getPrize())
                .betweenIfPresent(GroupOrderDO::getAddTime, reqVO.getAddTime())
                .eqIfPresent(GroupOrderDO::getGoods, reqVO.getGoods())
                .eqIfPresent(GroupOrderDO::getGroupGoodsId, reqVO.getGroupGoodsId())
                .eqIfPresent(GroupOrderDO::getPayStatus, reqVO.getPayStatus())
                .betweenIfPresent(GroupOrderDO::getPayTime, reqVO.getPayTime())
                .eqIfPresent(GroupOrderDO::getOrderStatus, reqVO.getOrderStatus())
                .orderByDesc(GroupOrderDO::getId));
    }

}
